import { $get, $post } from '@/utils';
const LANG = ['zh_CN', 'en'];
import { WPURL } from '@/config';
/**
 * User
 */

// 地址登录
export let addressLogin = (parms) => {
	return $post('/api/v1/user/addresslogin', parms);
};

//获取用户基本信息
export let userinfo = (parms) => {
	return $get('/api/v1/user/getinfo', parms);
};

//获取用户基本信息BY address
export let getUserInfoByAddress = (parms) => {
	return $get('/api/v1/user/getinfobyaddress', parms);
};

//创建竞拍
export let createNftBid = (parms) => {
	return $post('/api/v1/nftbid/create', parms);
};

//获取竞拍基本信息
export let nftBidInfo = (parms) => {
	return $get('/api/v1/nftbidlist/detail', parms);
};

//竞拍出价
export let submitNftBid = (parms) => {
	return $post('/api/v1/nftbid/submitbid', parms);
};

//用户最新出价
export let userLatestBidRecord = (parms) => {
	return $get('/api/v1/nftbid/latest', parms);
};

//支付回调
export let setnftbidpayed = (parms) => {
	return $post('/api/v1/nftbid/setpayed', parms);
};

//交易记录同步后台
export let createNftTrade = (parms) => {
	return $post('/api/v1/nfttrade/create', parms);
};

//nft信息同步后台
export let createNftInfo = (parms) => {
	return $post('/api/v1/nft/create', parms);
};






// 领英登录
export let linkedin = () => {
	return $post('/api/v1/login/linkedin', {});
};

export let linkedinlogin = (code) => {
	return $post('/api/v1/user/linkedinlogin', { code });
};
//微信登录
export let weixinlogin = (code) => {
	return $post('/api/v1/user/weixinlogin', { code });
};

//用户密码登录
export let userPasswordlogin = (parms) => {
	return $post('/api/v1/user/passwordlogin', parms);
};

//用户手机验证登录
export let userCodelogin = (parms) => {
	return $post('/api/v1/user/mobilelogin', parms);
};

//用户注册
export let userRegister = (parms) => {
	return $post('/api/v1/user/register', parms);
};

//重置密码（user ,institution 通用）
export let resetPassword = (parms) => {
	return $post('/api/v1/user/resetpassword', parms);
};

//用户基本信息更新
export let userUpdateinfo = (parms) => {
	return $post('/api/v1/user/updateinfo', parms);
};

// //获取用户基本信息
// export let userinfo = parms => {
//   return $get("/api/v1/user/getinfo", parms);
// };

//gettosflag
export let gettosflag = (parms) => {
	return $post('/api/v1/user/gettosflag', parms);
};

//settosflag
export let settosflag = (parms) => {
	return $post('/api/v1/user/settosflag', parms);
};


/**
 * 系统消息
 */
//消息列表
export let messageList = (parms) => {
	return $get('/api/v1/message/list', parms);
};
//消息详情
export let messageDetail = (parms) => {
	return $get('/api/v1/message/detail', parms);
};



/**
 * Misc 其他接口
 */
//阿里云OSS STStoken 需要auth
export let ststoken = (strAuthorization) => {
	return $get(
		'/api/v1/oss/getststoken',
		{},
		{
			Authorization: strAuthorization,
		}
	);
};

// 系统配置数据信息
export let masterdata = () => {
	return $get(
		'/api/v1/sys/masterdata',
		{},
		{
			// Authorization:'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI0IiwianRpIjoiYjE4MjhkMTBjOGQ1OWYwMmI5ZjgxZjhiYzc1NzQ2ZTM2ZmQxZjg3YmRhYWYyZmRmNjU3OWNiMTY5ZWU3ZTEyYzQ4OWIzZjc4ZmEyMWM0Y2UiLCJpYXQiOjE1OTczMDg0NzQsIm5iZiI6MTU5NzMwODQ3NCwiZXhwIjoxNTk4NjA0NDc0LCJzdWIiOiIyOCIsInNjb3BlcyI6WyIqIl19.a1E1R5NtjRmsyG4OOByMf7MdNypSmR2NLtujggOYu71RLh22m8wTXIkZTzqhBLXH_xK-jmiqy_9FouxTTWOP9n0XEj_1rE1zVaQqfI29ba4L1ZCifigMWaCRz2VqzFKCTJP9tZxqj6rtHZe0A-i2WYcaLrufh2e2kOwbX33zGqDS9Vfr09QCMcG8u2xGirIxAOKp_0BTrLVLrvDX-R5XChHJq67eWgkTK28LrIxAAfB-BdxgVMxvu-fs_CbXcX5Pbc3UWt594PYQaIBhtRFI50fHJ-q_chw71dCdG7LQTiEIkl_UdW6gpftL5L14_K_wzWLyFZq1v5T1wiiNlG0EKEAaUgN66--CA0SKIgryNiGqJL9WiXe1L9wBVgDc8oIVli2wILPBjR48xzinkC2j_GSDJkn3hJ5FgkXzsjbBQZ99B1OOgcKDDUG_REckWrFDgzktMsCdL94lXK60M4fjoQPGgVl0EwOH9PmP9yCMcwhvzp4pWxD9yk6J42NlPGrF1acNKZSGJQ_usuRyQr9q8MSBVbuWc_MXjCVolxt12FrdieHrt-ckleDH-sETKWrK5Gm50J1Y9VgxYH9vCt3WezTXhDjbY_yT9ovVFf03TOCKY2qIskP8WnYVoHCKcKqu_0LZZITXr35n2aU0rn-hvQqtY9AWwEJ8rKGpG_bziqQ'
		}
	);
};

export let getAuthorization = () => {
	return localStorage.getItem('Authorization');
};

//三级地址接口
export let areadata = (id) => {
	return $get(
		'/api/v1/sys/areadata',
		{ id },
		{
			// Authorization:'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI0IiwianRpIjoiYjE4MjhkMTBjOGQ1OWYwMmI5ZjgxZjhiYzc1NzQ2ZTM2ZmQxZjg3YmRhYWYyZmRmNjU3OWNiMTY5ZWU3ZTEyYzQ4OWIzZjc4ZmEyMWM0Y2UiLCJpYXQiOjE1OTczMDg0NzQsIm5iZiI6MTU5NzMwODQ3NCwiZXhwIjoxNTk4NjA0NDc0LCJzdWIiOiIyOCIsInNjb3BlcyI6WyIqIl19.a1E1R5NtjRmsyG4OOByMf7MdNypSmR2NLtujggOYu71RLh22m8wTXIkZTzqhBLXH_xK-jmiqy_9FouxTTWOP9n0XEj_1rE1zVaQqfI29ba4L1ZCifigMWaCRz2VqzFKCTJP9tZxqj6rtHZe0A-i2WYcaLrufh2e2kOwbX33zGqDS9Vfr09QCMcG8u2xGirIxAOKp_0BTrLVLrvDX-R5XChHJq67eWgkTK28LrIxAAfB-BdxgVMxvu-fs_CbXcX5Pbc3UWt594PYQaIBhtRFI50fHJ-q_chw71dCdG7LQTiEIkl_UdW6gpftL5L14_K_wzWLyFZq1v5T1wiiNlG0EKEAaUgN66--CA0SKIgryNiGqJL9WiXe1L9wBVgDc8oIVli2wILPBjR48xzinkC2j_GSDJkn3hJ5FgkXzsjbBQZ99B1OOgcKDDUG_REckWrFDgzktMsCdL94lXK60M4fjoQPGgVl0EwOH9PmP9yCMcwhvzp4pWxD9yk6J42NlPGrF1acNKZSGJQ_usuRyQr9q8MSBVbuWc_MXjCVolxt12FrdieHrt-ckleDH-sETKWrK5Gm50J1Y9VgxYH9vCt3WezTXhDjbY_yT9ovVFf03TOCKY2qIskP8WnYVoHCKcKqu_0LZZITXr35n2aU0rn-hvQqtY9AWwEJ8rKGpG_bziqQ'
		}
	);
};

/**
 * 验证码
 */

// 短信验证码
export let verifyMobile = (mobile, token, type, lang) => {
	if (mobile.length != 11) {
		return null;
	}
	return $post('/api/v1/verify/mobile', {
		mobile,
		token,
		type,
		lang,
	});
};

/**
 * 邮件验证码
 */
export let verifyEmail = (params) => {
	return $post('/api/v1/verify/email', params);
};

/**
 * 获取某大赛的指数信息字段列表
 */
export let itemList = (params) => {
	return $get('/api/v1/investigation/itemlist', params);
};

/**
 * 机构指数信息
 */
export let listInvestigation = (params) => {
	return $get('/api/v1/investigation/list', params);
};

/**
 * 用户机构提交指数信息
 */
export let submitInvestigation = (params) => {
	return $post('/api/v1/investigation/submit', params);
};

/**
 *  获得地址列表
 */
export let getAllAreaData = (params) => {
	return $get('/api/v1/sys/allareadata', params);
};

//获得咨询列表
export let requestNews = (parms) => {
	return $get(WPURL + '/wp-json/wp/v2/posts', parms, {}, true);
};

//获得咨询列表图片
export let requestThumb = (parms) => {
	return $get(
		WPURL + '/wp-json/wp/v2/media/' + parms.id + '?_fields=source_url',
		{},
		{},
		true
	);
};

/**
 * Ventures创投模块
 */

// 找投资 获取列表
export let institutionList = (
	{ institution_name, tags, focus_areas, areas, is_recommend } = {},
	page = 1,
	perPage = 15,
	lang = LANG[0]
) => {
	return $get('​/api/v1/findinstitution/list', {
		institution_name,
		tags, // 机构标签tags id 数组 例[31,32,33]
		focus_areas, // 关注领域id 数组 例[31,32,33]
		areas, // 二级地区id 数组 例[31,32,33]
		is_recommend, // 1 推荐
		page, // 页号 默认第一页
		perPage, // 每页条数 默认15
		lang, // 语言（zh_CN or en）
	});
};

//找项目 获取列表
export let projectlist = (
	{
		project_name,
		focus_areas,
		finance_stages,
		areas,
		industrys,
		found_years,
		is_recommend,
	} = {},
	page = 1,
	perPage = 15,
	lang = LANG[0]
) => {
	return $get('​/api/v1/findproject/list', {
		project_name, // 名称模糊查询
		focus_areas, // 关注领域id 数组 例[31,32,33]
		finance_stages, // 融资阶段id 数组 例[31,32,33]
		areas, // 二级地区id 数组 例[31,32,33]
		industrys, // 行业id 数组 例[31,32,33]
		found_years, // 成立年限id 数组 例[2010,2011,2012]
		is_recommend, // 1 推荐
		page, // 页号 默认第一页
		perPage, // 每页条数 默认15
		lang, // 语言（zh_CN or en）
	});
};

// 机构信息
export let institutiondetailinfo = (parms) => {
	return $post('/api/v1/institutiondetailinfo/index', parms);
};
// 创投数据统计
export let pagedata = () => {
	return $get('/api/v1/findproject/pagedata', {}, {});
};

/**
 *Vip VIP模块
 */

//  购买vip
export let getQRCode = () => {
	return $post('/api/v1/vip/buy');
};

// 订单列表
export let orderList = (page, perPage, sortItem, lang = LANG[0]) => {
	return $post(
		'/api/v1/order/list',
		{},
		{
			params: {
				page,
				perPage,
				sortItem,
				lang,
			},
		}
	);
};

// 订单状态
export let orderStatus = (orderNo, lang = LANG[0]) => {
	return $post(
		'/api/v1/order/status',
		{},
		{
			params: {
				lang,
				orderNo,
			},
		}
	);
};
